package com.bahiaapk;

import com.bahiaapk.services.SynchronizeAudio;
import com.raptureinvenice.webimageview.image.WebImageView;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;


public class MediaPlayerActivity  extends Activity implements OnClickListener { 
	  private Button buttonStart;
	  private Button buttonStop; 
      private Display display;
	  private Integer heightScreen;
      private RelativeLayout layoutWebview;

	  @Override 
	  public void onCreate(Bundle savedInstanceState) { 
		  
		  super.onCreate(savedInstanceState); 
		  setContentView(R.layout.my_player); 
	
		  buttonStart = (Button) findViewById(R.id.buttonStart); 
		  buttonStop = (Button) findViewById(R.id.buttonStop); 
	        layoutWebview = (RelativeLayout) findViewById(R.id.layout_webview);

		  buttonStart.setOnClickListener(this); 
		  buttonStop.setOnClickListener(this); 
		  
		  fixScreenSize();
	  } 

	  public void onClick(View src) { 
		  switch (src.getId()) { 
		  	case R.id.buttonStart: 
		  		startService(new Intent(this, SynchronizeAudio.class)); 
		  	break; 
		  	case R.id.buttonStop: 
		  		stopService(new Intent(this, SynchronizeAudio.class)); 
		  	break; 
	  	  } 
	  } 
	  
	  private void fixScreenSize() {
			display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
			
	        heightScreen = display.getHeight();
	        int newValue = (int) (heightScreen*0.68);
	        
	        layoutWebview.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, newValue));
		}
		
		
}